/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.equipment.service;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.persistence.Result;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.modules.equipment.dao.EleEquipmentDao;
import com.thinkgem.jeesite.modules.equipment.entity.EleEquipment;
import com.thinkgem.jeesite.modules.sys.entity.User;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.sql.Date;
import java.util.List;

/**
 * 设备管理Service
 * @author ZC
 * @version 2017-04-18
 */
@Service
@Transactional(readOnly = true)
public class EleEquipmentService extends CrudService<EleEquipmentDao, EleEquipment> {

	
	public EleEquipment get(String id) {
		EleEquipment eleEquipment = super.get(id);
		return eleEquipment;
	}
	
	public List<EleEquipment> findList(EleEquipment eleEquipment) {
		return super.findList(eleEquipment);
	}
	
	public Page<EleEquipment> findPage(Page<EleEquipment> page, EleEquipment eleEquipment) {
		return super.findPage(page, eleEquipment);
	}
	public Page<EleEquipment> findPageForCheck(Page<EleEquipment> page, List<User> users,String status) {
		page.setList(dao.findEleEquipmentForCheck(users, status));
		return page;
	}
	@Transactional(readOnly = false)
	public void updatePublishStatus(String publishId,String status) {
		dao.updatePublishStatus(publishId, status);
	}
	@Transactional(readOnly = false)
	public void updateOnlineStatus(String publishId,String status) {
		dao.updateOnlineStatus(publishId, status);
	}
	@Transactional(readOnly = false)
	public void save(EleEquipment eleEquipment) {
		super.save(eleEquipment);
	}
	
	@Transactional(readOnly = false)
	public void delete(EleEquipment eleEquipment) {
		super.delete(eleEquipment);
	}

	@Transactional(readOnly = false)
	public Result checkEquipment(EleEquipment eleEquipment){
		int result = dao.check(eleEquipment);
		if(result>0){
			return new Result(Result.SUCCESS, "审核操作成功!", null);
		}else{
			return new Result(Result.FAILURE, "审核操作完成!", null);
		}
	}

	@Transactional(readOnly = false)
	public void saveFloorMapping(EleEquipment eleEquipment){
		dao.saveFloorMapping(eleEquipment);
	}

	@Transactional(readOnly = false)
	public int delApprovalEquipmentStatus(String equipments, String status){
		return dao.delApprovalEquipmentStatus(equipments, status);
	}

	@Transactional(readOnly = false)
	public int delApplyEquipmentStatus(String equipments, String status){
		return dao.delApplyEquipmentStatus(equipments, status);
	}

	@Transactional(readOnly = false)
	public int bathcUpdateEquipmentStatus(String equipments, String status, String checker){
		return dao.bathcUpdateEquipmentStatus(equipments, status, checker);
	}

    @Transactional(readOnly = false)
	public int eleEquipmentIsOnLine(String mac, Date date){
        return dao.eleEquipmentIsOnLine(mac, "1", date);
    }

	@Transactional(readOnly = false)
	public int saveConfig(EleEquipment equipment){
		return dao.saveConfig(equipment);
	}
    @Transactional(readOnly = false)
    public int uploadingConfig(EleEquipment equipment){
        return dao.uploadingConfig(equipment);
    }

	public EleEquipment findEquipmentConfigByCode(String mac){
		return dao.findEquipmentConfigByCode(mac);
	}

	public EleEquipment equipmentConfig(String mac){
        return dao.findEquipmentConfigByCode(mac);
	}

	public EleEquipment findEquipmentByCode(String code){
		return dao.findEquipmentByCode(code);
	}
}